using System.Collections.Generic;
using UnityEngine;
using UnityGameFramework.Runtime;

namespace LS
{
    public class BuiltinDataComponent : CustomGameFrameworkComponent
    {
        [SerializeField]
        private List<TextAsset> m_DefaultConfigs = new List<TextAsset>();
        
        [SerializeField]
        private List<TextAsset> m_DefaultLanguageDictionary = new List<TextAsset>();

        public void InitConfigs()
        {
            if(m_DefaultConfigs.Count == 0)
                return;
            
            foreach (var data in m_DefaultConfigs)
            {
                if (!LSEntry.Config.ParseData(data.text))
                {
                    Log.Warning($"Parse config failure. Config Name:[{data.name}]");
                }
            }
        }

        public void InitDefaultLanguageDictionary()
        {
            if(m_DefaultLanguageDictionary.Count == 0)
                return;
            
            foreach (var data in m_DefaultLanguageDictionary)
            {
                if (!LSEntry.Localization.ParseData(data.text))
                {
                    Log.Warning($"Parse dictionary failure. Config Name:[{data.name}]");
                }
            }
        }
    }
}
